import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

// 引入字体图标
import './assets/fonts/iconfont.css'

// 引入全局样式表
import './assets/css/global.css'

import TreeTable from 'vue-table-with-tree-grid'

// 引入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

// 引入 axios
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 请求拦截器添加 token
axios.interceptors.request.use(function (config) {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios

Vue.config.productionTip = false

Vue.component('tree-table', TreeTable)

Vue.filter('dataFormat', function (val) {
  let date = new Date(val)
  let y = date.getFullYear()
  let m = (date.getMonth() + 1 + '').padStart(2, '0')
  let d = (date.getDate() + '').padStart(2, '0')
  let h = (date.getHours() + '').padStart(2, '0')
  let Minute = (date.getMinutes() + '').padStart(2, '0')
  let s = (date.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d}-${h}-${Minute}-${s}`
})

// 将富文本编辑器注册为全局组件
Vue.use(VueQuillEditor)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
